################################################################################
#
# nxp s32 alb demos features
#
################################################################################
ALB_DEMO_VERSION = bsp43.0
ALB_DEMO_SITE = package/nxp/s32/alb-demo/alb-demos-$(ALB_DEMO_VERSION)
ALB_DEMO_SITE_METHOD = local

ALB_DEMO_MAKE_OPTS += \
	CROSS_COMPILE=$(TARGET_CROSS)

# 构建 multicore sample
ifeq ($(BR2_PACKAGE_ALB_DEMO_MULTICORE),y)
define ALB_DEMO_MULTICORE_BUILD_CMDS
	$(TARGET_MAKE_ENV) $(MAKE1) -C $(@D) $(ALB_DEMO_MAKE_OPTS) multicore
endef

define ALB_DEMO_MULTICORE_INSTALL_TARGET_CMDS
	$(INSTALL) -D -m 755 $(@D)/multicore/multicore $(TARGET_DIR)/usr/sbin/multicore
endef
endif

# 构建 gpio_libgpiod sample
ifeq ($(BR2_PACKAGE_ALB_DEMO_GPIO_LIBGPIOD),y)
ALB_DEMO_DEPENDENCIES += libgpiod
define ALB_DEMO_GPIO_LIBGPIOD_BUILD_CMDS
	$(TARGET_MAKE_ENV) $(MAKE1) -C $(@D) $(ALB_DEMO_MAKE_OPTS) gpio_libgpiod
endef

define ALB_DEMO_GPIO_LIBGPIOD_INSTALL_TARGET_CMDS
	$(INSTALL) -D -m 755 $(@D)/gpio_libgpiod/gpio_libgpiod $(TARGET_DIR)/usr/sbin/gpio_libgpiod
endef
endif

# 构建 networking sample
ifeq ($(BR2_PACKAGE_ALB_DEMO_NETWORKING),y)
ALB_DEMO_SAMPLES += networking
define ALB_DEMO_NETWORKING_BUILD_CMDS
	$(TARGET_MAKE_ENV) $(MAKE1) -C $(@D) $(ALB_DEMO_MAKE_OPTS) networking
endef

define ALB_DEMO_NETWORKING_INSTALL_TARGET_CMDS
	$(INSTALL) -D -m 755 $(@D)/networking/server $(TARGET_DIR)/usr/sbin/server
	$(INSTALL) -D -m 755 $(@D)/networking/server_multiclient $(TARGET_DIR)/usr/sbin/server_multiclient
	$(INSTALL) -D -m 755 $(@D)/networking/client $(TARGET_DIR)/usr/sbin/client
endef
endif

# 构建 pcie sample
ifeq ($(BR2_PACKAGE_ALB_DEMO_PCIE),y)
define ALB_DEMO_PCIE_BUILD_CMDS
	$(TARGET_MAKE_ENV) $(MAKE1) -C $(@D) $(ALB_DEMO_MAKE_OPTS) pcie_shared_mem
endef

define ALB_DEMO_PCIE_INSTALL_TARGET_CMDS
	$(INSTALL) -D -m 755 $(@D)/pcie_shared_mem/pcie_ep/test_ep $(TARGET_DIR)/usr/sbin/test_ep
	$(INSTALL) -D -m 755 $(@D)/pcie_shared_mem/pcie_rc/test_rc $(TARGET_DIR)/usr/sbin/test_rc
endef
endif

# 构建 pcie_virt_eth
ifeq ($(BR2_PACKAGE_ALB_DEMO_PCIE_VIRT_ETH),y)
define ALB_DEMO_PCIE_VIRT_ETH_BUILD_CMDS
	$(TARGET_MAKE_ENV) $(MAKE1) -C $(@D) $(ALB_DEMO_MAKE_OPTS) pcie_virt_eth
endef

define ALB_DEMO_PCIE_VIRT_ETH_INSTALL_TARGET_CMDS
endef
endif

define ALB_DEMO_BUILD_CMDS
	$(ALB_DEMO_MULTICORE_BUILD_CMDS)
	$(ALB_DEMO_GPIO_LIBGPIOD_BUILD_CMDS)
	$(ALB_DEMO_NETWORKING_BUILD_CMDS)
	$(ALB_DEMO_PCIE_BUILD_CMDS)
	$(ALB_DEMO_PCIE_VIRT_ETH_BUILD_CMDS)
endef

define ALB_DEMO_INSTALL_TARGET_CMDS
	$(ALB_DEMO_MULTICORE_INSTALL_TARGET_CMDS)
	$(ALB_DEMO_GPIO_LIBGPIOD_INSTALL_TARGET_CMDS)
	$(ALB_DEMO_NETWORKING_INSTALL_TARGET_CMDS)
	$(ALB_DEMO_PCIE_INSTALL_TARGET_CMDS)
	$(ALB_DEMO_PCIE_VIRT_ETH_INSTALL_TARGET_CMDS)
endef

$(eval $(generic-package))
